home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / G4C / CED / cedbar.gc < prev    next >
Text File  |  1999-04-21  |  16KB  |  600 lines

  1. G4C
  2.  
  3. ; $VER: CedBar.gc 3.5 ( by dck - 20.8.98 )
  4. ; ----------------------------------------------------------------------
  5. ; A GUI providing a toolbar for the CygnusEd text editor.
  6. ; This is a work in perpetual progress, as I use it myself..
  7. ; CygnusEd is a commercial product from ASDG Inc. (AFAIK)
  8.  
  9. ; What we do is define various icons, which we use as if they 
  10. ; were buttons and send the appropriate rexx command to $cedport, 
  11. ; which contains the name of the current CEd's arexx port.
  12.  
  13. ; According to your monitor/resolution/font etc the Icon-buttons may 
  14. ; seem too small or too big - just redesign them to your liking.
  15.  
  16. ; =======================================================================
  17.  
  18. WINBIG -1 0 625 14 "" ; note : no title - since don't want borders
  19. WinType 000010
  20. ; winbackground pattern 3 2 ; try it..
  21. varpath 'cedbar.g/cedmark.g'
  22. UseTopaz        ; because it's a non-resizable window
  23.  
  24. ; -----------------------------------------------------------
  25. ;       on loading
  26. ; -----------------------------------------------------------
  27.  
  28. xOnLoad
  29.  
  30. TTget :cedbar.gc        ; read in out icon's tool types
  31. if $CEDPATH > ' '        ; tells us the full path of ced
  32.    cedname = $CEDPATH
  33. else
  34.    cedname = CEd        ; << *** PUT HERE THE FULL PATH OF CED ***
  35. endif
  36.  
  37. cedClip = 0
  38. cedMark = 1
  39. cedSend = ""
  40. cedFile = ""
  41. newflag = 0
  42. Update cedbar.gc 1 $cedClip
  43. setgad cedbar.gc 20 HIDE     ; hide listview
  44. setgad cedbar.gc 11/12 HIDE    ; hide amiga guide & launch mode icons
  45. barmode = NORMAL        ; or GUIDE - can add more..
  46. GuiClose cedbar.g          ; Close the small window (if it was open)
  47.  
  48. gosub cedbar.gc StartUpCed      ; See which ced is calling us
  49. if $$sys.fsn[0][6] != 'Cygnus'  ; if we are called from an other screen
  50.    cedscreen = CygnusEdScreen   ; get the 1st ced's screen name
  51.    instance = $cedport[-1][1]
  52.    if $instance > 0
  53.    and $instance <= 9
  54.        appvar cedscreen $($instance + 1) 
  55.    else
  56.        appvar cedscreen 1 
  57.    endif
  58.    guiscreen #$cedscreen front  ; force ced to front
  59. endif
  60. GuiOpen  cedbar.gc
  61.  
  62. GuiLoad :cedbar.g        ; the small bar
  63. GuiLoad :cedMark.g        ; the Mark Set/Go window
  64. GuiLoad :cedclip.g        ; clipboard viewer
  65. guiload guis:tools/filereq.gc   ; the file requester
  66.  
  67. ; see under which ced we're running..
  68. info gui cedbar.gc
  69. cedscreen = $$win.screen
  70. cedport = rexx_ced
  71. if $cedscreen[0][6] == 'Cygnus'   ; make sure it's a ced pubscreen
  72.    instance = $cedscreen[-1][1]   ; get last letter
  73.    if $instance > 1
  74.    and $instance <= 9          ; adjust port name (if needed)
  75.        appvar cedport $($instance - 1) 
  76.    endif
  77. endif
  78.  
  79. ; find & load the Gui4Cli extension which provides us with 
  80. ; extra commands we can use with the CALL command
  81. ifexists port LVFormat
  82.    call LVFormat Register         ; notify it that we want it too
  83. else
  84.    ; look in our dir..
  85.    extract cedbar.gc guipath mypath
  86.    joinfile $mypath lvformat progname
  87.    joinfile $progname lvformat progname
  88.    ifexists file $progname
  89.       run $progname
  90.    elseifexists file guis:ext/lvformat/lvformat
  91.       run guis:ext/lvformat/lvformat
  92.    else
  93.       ezreq 'Could not find LVFormat!' OK ''
  94.    endif
  95. endif
  96.  
  97. ; -----------------------------------------------------------
  98. ;       ending events
  99. ; -----------------------------------------------------------
  100.  
  101. xONQuit
  102. GuiQuit cedbar.g        ; unload all the other GUIs
  103. GuiQuit cedmark.g
  104. guiquit cedclip.g
  105. guiquit addlink.g
  106. guiquit addeffect.g
  107. guiquit addnode.g
  108. guiquit indent.g
  109. guiquit wrap.g
  110. guiquit filereq.gc
  111. ifexists port LVFormat    ; quit out handler
  112.    call LVFormat quit
  113. endif
  114. ifexists file t:tempnode
  115.    delete t:tempnode
  116. endif
  117.  
  118. xonfail
  119. guiwindow cedbar.gc resume
  120.  
  121. ; -----------------------------------------------------------
  122. ;       Routine - Find ced
  123. ; -----------------------------------------------------------
  124.  
  125. xRoutine StartUpCed
  126. local count
  127. count = 1
  128.  
  129. portname = rexx_ced
  130.  
  131. ; look for any instance of ced
  132. ifexists port ~rexx_ced
  133.    while $count < 10
  134.       IfExists PORT 'rexx_ced$count'
  135.          portname = 'rexx_ced$count'
  136.          return
  137.       endif
  138.       ++count
  139.    endwhile
  140. else
  141.    return
  142. endif
  143.  
  144. run '$cedname'        ; not found - start it up
  145. Wait PORT rexx_ced 30   ; wait for ced to load
  146. if $$RETCODE > 0
  147.    ezreq "CygnusEd was not found!\nPlease enter the full path & name of\nthe CygnusEd program in the Icon Tooltypes\nof the CedBar.gc icon." EXIT ""
  148.    GuiQuit cedbar.gc
  149.    Stop
  150. endif
  151. Wait SCREEN CygnusEdScreen1 30     ; if Screen does not open, use WB
  152. portname = rexx_ced
  153.  
  154. ; -----------------------------------------------------------
  155. ;       window handling events
  156. ; -----------------------------------------------------------
  157.  
  158. xOnRMB              ; rotate the last 8 buttons
  159. ; GuiClose cedbar.gc
  160. ; GuiOpen cedbar.g
  161. gosub cedbar.gc guichange
  162.  
  163. XICON 2 0 :icons/wnClose   ; the Q icon
  164. ezreq "Last chance..\nQuit ?" YES|CANCEL choice
  165. if $choice = 1
  166.    GuiQuit cedbar.gc
  167. endif
  168.  
  169. XICON 15 1 :icons/right    ; the > icon togle big/small windows
  170. GuiClose cedbar.gc
  171. GuiOpen cedbar.g
  172.  
  173. ; -----------------------------------------------------------
  174. ;       New file
  175. ; -----------------------------------------------------------
  176.  
  177. XICON 30 0 :icons/New
  178. SendRexx $cedport "open new"
  179.  
  180. ; -----------------------------------------------------------
  181. ;       Open file
  182. ; -----------------------------------------------------------
  183. ; ----- use "filereq.gc" (if it exists in our dir - else ASL)
  184.  
  185. XICON 55 0 :icons/Open
  186. newflag = 1     ; set flag to know that we pressed the open button
  187. ifexists file guis:tools/filereq.gc
  188.     ; get the current filename so we can get it's path
  189.     sendrexx $cedport 'status filename'
  190.     filename = $$rexxret
  191.     extract filename path path
  192.     ; load & open filereq.gc
  193.     guiload guis:tools/filereq.gc cedbar.gc LoadFile $cedbar.gc/path guis:tools/fav/CedFav
  194. else
  195.     ; if no filereq.gc open normally
  196.     SendRexx $cedport "open"
  197. endif
  198.  
  199. ; ----- the routine that will be called from filereq.gc for *every*
  200. ;       file chosen in it's listview
  201.  
  202. xroutine LoadFile filename
  203. ; if there have been changes made or it's an existing file - open a new file
  204.   sendrexx $cedport 'status numchanges'
  205.   changes = $$rexxret
  206.   if $newflag = 0
  207.   or $changes > 0
  208.      SendRexx $cedport "open new"
  209.   endif
  210.   newflag = 0   ; set flag = all next files (multiselected) => open new view
  211.   SendRexx $cedport 'open $filename'
  212.  
  213. ; ------ add current path to the filename - store it in cedbar.gc/fn
  214.  
  215. xroutine makefile fn
  216.   local pth
  217.   extract cedbar.gc guipath pth
  218.   joinfile $pth $fn fn
  219.  
  220.  
  221. ; -----------------------------------------------------------
  222. ;       View handling icons
  223. ; -----------------------------------------------------------
  224.  
  225. XICON 80 0 :icons/Big
  226.   SendRexx $cedport "expand view"
  227.  
  228. ; -----------------------------------------------------------
  229. ;       Save as.., Save
  230. ; -----------------------------------------------------------
  231.  
  232. XICON 95 0 :icons/saveas
  233. SendRexx $cedport "save as"
  234.  
  235. XICON 120 0 :icons/save
  236. SendRexx $cedport "save"
  237.  
  238. ; -----------------------------------------------------------
  239. ;       Quit
  240. ; -----------------------------------------------------------
  241.  
  242. XICON 145 0 :icons/quit
  243. ; get information
  244. sendrexx $cedport 'status numchanges'
  245. changes = $$rexxret
  246. sendrexx $cedport 'status filename'
  247. filename = $$rexxret
  248. sendrexx $cedport 'status totalnumviews'
  249. views = $$rexxret
  250. if $changes > 0
  251.    ezreq '$changes changes have been made.\nQuit $filename ?\n' 'Quit|Save & Quit|CANCEL' choice
  252.    if $choice = 0
  253.       stop
  254.    elseif $choice = 2
  255.       SendRexx $cedport "save"
  256.       ; we will quit later..
  257.    endif
  258. endif
  259. if $views = 1   ; this is the last file - give him one more chance..
  260.    ezreq 'Really quit ?' "Quit!|CANCEL" choice
  261.    if $choice = 0
  262.       stop
  263.    endif
  264.    ; the guy just won't listen to reason..
  265.    guiclose cedbar.gc   ; close window so ced can quit
  266.    guiclose cedmark.g
  267.    guiquit cedbar.gc    ; and quit.. (after all commands have executed)
  268. endif
  269. SendRexx $cedport "quit"
  270.  
  271. ; -----------------------------------------------------------
  272. ;       Cut & Paste
  273. ; -----------------------------------------------------------
  274.  
  275. XICON 170 0 :icons/cut
  276. SendRexx $cedport cut
  277. lvuse CedClip.g 1
  278. lvchange 'CLIPS:$cedClip'
  279.  
  280. XICON 195 0 :icons/copy
  281. SendRexx $cedport copy
  282. lvuse CedClip.g 1
  283. lvchange 'CLIPS:$cedClip'
  284.  
  285. XICON 220 0 :icons/paste
  286. SendRexx